package com.example.practice.controller;

import com.example.practice.entity.*;
import com.example.practice.service.MiddleSchoolService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;
import java.util.List;

import javax.annotation.Resource;

/**
 * (MiddleSchool)表控制层
 *
 * @author makejava
 * @since 2023-12-29 11:02:00
 */
@RestController
@RequestMapping("/api/middleSchool")
@Api(tags = "MiddleSchoolController")
public class MiddleSchoolController {
    @Resource
    private MiddleSchoolService middleSchoolService;

    @ApiOperation("通过uid查询相关生源中学")
    @GetMapping("/getAllByUidPage")
    public respMsg getAllByUidPage(Integer uid, pageMsg pageMsg) {
        respMsg respMsg = this.middleSchoolService.getAllByUidPage(uid, pageMsg);
        return respMsg;
    }

    @ApiOperation("通过uid查询相关生源中学的录取总人数")
    @GetMapping("/getSumByUid")
    public List<MiddleSum> getSumByUid(Integer uid) {
        List<MiddleSum> middleSums = this.middleSchoolService.getSumByUid(uid);
        return middleSums;
    }

    @ApiOperation("通过mid(生源中学id)和uid查询相关生源中学的每年录取人数")
    @GetMapping("/getAdmission")
    public List<AdmiYear> getAdmission(Integer mid, Integer uid) {
        List<AdmiYear> admiYears = this.middleSchoolService.getAdmission(mid, uid);
        return admiYears;
    }

    @ApiOperation("获取中学信息")
    @GetMapping("/getMiddleSchool")
    public List<MiddleSchool> getMiddleSchool(){
        return this.middleSchoolService.getMiddleSchool();
    }
    @ApiOperation("学生报名时候的选择中学")
    @GetMapping("/joinMiddleSchool")
    public List<MiddleSchool> joinMiddleSchool(Integer aid){
        return this.middleSchoolService.joinMiddleSchool(aid);
    }

    @ApiOperation("插入中学信息")
    @PostMapping("/insertMiddleSchool")
    public Integer insertMiddleSchoole(@RequestBody List<MiddleSchool> middleSchools){
        System.out.println(middleSchools);
        return this.middleSchoolService.insertMiddleSchool(middleSchools);
    }

    @ApiOperation("插入录取信息")
    @PostMapping("/insertAdmission")
    public Integer insertAdmission(@RequestBody List<Admission> admissions){
        System.out.println(admissions);
        return this.middleSchoolService.insertAdmission(admissions);
    }

    @ApiOperation("通过uid查询相关生源中学,无分页")
    @GetMapping("/getAllAdmiByUid")
    public List<MiddleSchool> getAllAdmiByUid(Integer uid) {
        List<MiddleSchool> respMsg = this.middleSchoolService.getAllAdmiByUid(uid);
        return respMsg;
    }
}

